<?php
namespace App\Models\CacheDb;
use App\Models\ConstCode;
use App\Models\MysqlDb\Sys\Config as ConfigModel;

/**
 * ConfigCache
 */
class Config extends CommonModel {

    protected $table;
    protected $cache_key = 'ConfigCache';
    protected $second = 5;

    public function __construct(){
        $this->table = $this->cache_key;
    }

    /**
     * 获取全部config
     * @return array
     */
    static public function getAll(){
        $cache = new self();
        $result = $cache->getValue();
        if(empty($result)){
            $config = new ConfigModel();
            $result = $config::getAll();
            $cache->setValue($result);
        }
        return $result;
    }

}
